home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / manual-p / man_db-2.000 / man_db-2 / man_db-2.3.10 / lib / glob.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-17  |  15.9 KB  |  676 lines

  1. /* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
  2.  
  3. This library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Library General Public License as
  5. published by the Free Software Foundation; either version 2 of the
  6. License, or (at your option) any later version.
  7.  
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11. Library General Public License for more details.
  12.  
  13. You should have received a copy of the GNU Library General Public
  14. License along with this library; see the file COPYING.LIB.  If
  15. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  16. Cambridge, MA 02139, USA.  */
  17.  
  18. /* AIX requires this to be the first thing in the file.  */
  19. #if defined (_AIX) && !defined (__GNUC__)
  20.  #pragma alloca
  21. #endif
  22.  
  23. #ifdef    HAVE_CONFIG_H
  24. #include "config.h"
  25. #endif
  26.  
  27. #include <errno.h>
  28. #include <sys/types.h>
  29.  
  30.  
  31. /* Comment out all this code if we are using the GNU C Library, and are not
  32.    actually compiling the library itself.  This code is part of the GNU C
  33.    Library, but also included in many other GNU distributions.  Compiling
  34.    and linking in this code is a waste when using the GNU C library
  35.    (especially if it is a shared library).  Rather than having every GNU
  36.    program understand `configure --with-gnu-libc' and omit the object files,
  37.    it is simpler to just do this in the source for each such file.  */
  38.  
  39. #if defined (_LIBC) || !defined (__GNU_LIBRARY__)
  40.  
  41.  
  42. #ifdef    STDC_HEADERS
  43. #include <stddef.h>
  44. #endif
  45.  
  46. #ifdef    HAVE_UNISTD_H
  47. #include <unistd.h>
  48. #ifndef POSIX
  49. #ifdef    _POSIX_VERSION
  50. #define    POSIX
  51. #endif
  52. #endif
  53. #endif
  54.  
  55. #if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS)
  56. extern int errno;
  57. #endif
  58.  
  59. #ifndef    NULL
  60. #define    NULL    0
  61. #endif
  62.  
  63.  
  64. #if    defined (POSIX) || defined (HAVE_DIRENT_H) || defined (__GNU_LIBRARY__)
  65. #include <dirent.h>
  66. #ifndef    __GNU_LIBRARY__
  67. #define D_NAMLEN(d) strlen((d)->d_name)
  68. #else    /* GNU C library.  */
  69. #define D_NAMLEN(d) ((d)->d_namlen)
  70. #endif    /* Not GNU C library.  */
  71. #else    /* Not POSIX or HAVE_DIRENT_H.  */
  72. #define direct dirent
  73. #define D_NAMLEN(d) ((d)->d_namlen)
  74. #ifdef    HAVE_SYS_NDIR_H
  75. #include <sys/ndir.h>
  76. #endif    /* HAVE_SYS_NDIR_H */
  77. #ifdef    HAVE_SYS_DIR_H
  78. #include <sys/dir.h>
  79. #endif    /* HAVE_SYS_DIR_H */
  80. #ifdef HAVE_NDIR_H
  81. #include <ndir.h>
  82. #endif    /* HAVE_NDIR_H */
  83. #endif    /* POSIX or HAVE_DIRENT_H or __GNU_LIBRARY__.  */
  84.  
  85. #if defined (POSIX) && !defined (__GNU_LIBRARY__)
  86. /* Posix does not require that the d_ino field be present, and some
  87.    systems do not provide it. */
  88. #define REAL_DIR_ENTRY(dp) 1
  89. #else
  90. #define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
  91. #endif /* POSIX */
  92.  
  93. #if    (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__))
  94. #include <stdlib.h>
  95. #include <string.h>
  96. #define    ANSI_STRING
  97. #else    /* No standard headers.  */
  98.  
  99. #ifdef HAVE_STRING_H
  100. #include <string.h>
  101. #define    ANSI_STRING
  102. #else
  103. #include <strings.h>
  104. #endif
  105. #ifdef    HAVE_MEMORY_H
  106. #include <memory.h>
  107. #endif
  108.  
  109. extern char *malloc (), *realloc ();
  110. extern void free ();
  111.  
  112. extern void qsort ();
  113. extern void abort (), exit ();
  114.  
  115. #endif    /* Standard headers.  */
  116.  
  117. #ifndef    ANSI_STRING
  118.  
  119. #ifndef    bzero
  120. extern void bzero ();
  121. #endif
  122. #ifndef    bcopy
  123. extern void bcopy ();
  124. #endif
  125.  
  126. #define    memcpy(d, s, n)    bcopy ((s), (d), (n))
  127. #define    strrchr    rindex
  128. /* memset is only used for zero here, but let's be paranoid.  */
  129. #define    memset(s, better_be_zero, n) \
  130.   ((void) ((better_be_zero) == 0 ? (bzero((s), (n)), 0) : (abort(), 0)))
  131. #endif    /* Not ANSI_STRING.  */
  132.  
  133. #ifndef    HAVE_STRCOLL
  134. #define    strcoll    strcmp
  135. #endif
  136.  
  137.  
  138. #ifndef    __GNU_LIBRARY__
  139. #ifdef    __GNUC__
  140. __inline
  141. #endif
  142. static char *
  143. my_realloc (p, n)
  144.      char *p;
  145.      unsigned int n;
  146. {
  147.   /* These casts are the for sake of the broken Ultrix compiler,
  148.      which warns of illegal pointer combinations otherwise.  */
  149.   if (p == NULL)
  150.     return (char *) malloc (n);
  151.   return (char *) realloc (p, n);
  152. }
  153. #define    realloc    my_realloc
  154. #endif
  155.  
  156.  
  157. #if    !defined(__alloca) && !defined(__GNU_LIBRARY__)
  158.  
  159. #ifdef    __GNUC__
  160. #undef    alloca
  161. #define    alloca(n)    __builtin_alloca (n)
  162. #else    /* Not GCC.  */
  163. #if    defined (sparc) || defined (HAVE_ALLOCA_H)
  164. #include <alloca.h>
  165. #else    /* Not sparc or HAVE_ALLOCA_H.  */
  166. #ifndef    _AIX
  167. extern char *alloca ();
  168. #endif    /* Not _AIX.  */
  169. #endif    /* sparc or HAVE_ALLOCA_H.  */
  170. #endif    /* GCC.  */
  171.  
  172. #define    __alloca    alloca
  173.  
  174. #endif
  175.  
  176. #ifndef    STDC_HEADERS
  177. #undef    size_t
  178. #define    size_t    unsigned int
  179. #endif
  180.  
  181. /* Some system header files erroneously define these.
  182.    We want our own definitions from <fnmatch.h> to take precedence.  */
  183. #undef    FNM_PATHNAME
  184. #undef    FNM_NOESCAPE
  185. #undef    FNM_PERIOD
  186. #ifdef HAVE_FNMATCH_H
  187. #  include <fnmatch.h>
  188. #else
  189. #  include "fnmatch.h"
  190. #endif
  191.  
  192. /* Some system header files erroneously define these.
  193.    We want our own definitions from <glob.h> to take precedence.  */
  194. #undef    GLOB_ERR
  195. #undef    GLOB_MARK
  196. #undef    GLOB_NOSORT
  197. #undef    GLOB_DOOFFS
  198. #undef    GLOB_NOCHECK
  199. #undef    GLOB_APPEND
  200. #undef    GLOB_NOESCAPE
  201. #undef    GLOB_PERIOD
  202. #include "glob.h"
  203.  
  204. __ptr_t (*__glob_opendir_hook) __P ((const char *directory));
  205. const char *(*__glob_readdir_hook) __P ((__ptr_t stream));
  206. void (*__glob_closedir_hook) __P ((__ptr_t stream));
  207.  
  208. static int glob_pattern_p __P ((const char *pattern, int quote));
  209. static int glob_in_dir __P ((const char *pattern, const char *directory,
  210.                  int flags,
  211.                  int (*errfunc) __P ((const char *, int)),
  212.                  glob_t *pglob));
  213. static int prefix_array __P ((const char *prefix, char **array, size_t n));
  214. static int collated_compare __P ((const __ptr_t, const __ptr_t));
  215.  
  216. /* Do glob searching for PATTERN, placing results in PGLOB.
  217.    The bits defined above may be set in FLAGS.
  218.    If a directory cannot be opened or read and ERRFUNC is not nil,
  219.    it is called with the pathname that caused the error, and the
  220.    `errno' value from the failing call; if it returns non-zero
  221.    `glob' returns GLOB_ABEND; if it returns zero, the error is ignored.
  222.    If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
  223.    Otherwise, `glob' returns zero.  */
  224. int
  225. glob (pattern, flags, errfunc, pglob)
  226.      const char *pattern;
  227.      int flags;
  228.      int (*errfunc) __P ((const char *, int));
  229.      glob_t *pglob;
  230. {
  231.   const char *filename;
  232.   char *dirname;
  233.   size_t dirlen;
  234.   int status;
  235.   int oldcount;
  236.  
  237.   if (pattern == NULL || pglob == NULL || (flags & ~__GLOB_FLAGS) != 0)
  238.     {
  239.       errno = EINVAL;
  240.       return -1;
  241.     }
  242.  
  243.   /* Find the filename.  */
  244.   filename = strrchr (pattern, '/');
  245.   if (filename == NULL)
  246.     {
  247.       filename = pattern;
  248.       dirname = (char *) ".";
  249.       dirlen = 0;
  250.     }
  251.   else if (filename == pattern)
  252.     {
  253.       /* "/pattern".  */
  254.       dirname = (char *) "/";
  255.       dirlen = 1;
  256.       ++filename;
  257.     }
  258.   else
  259.     {
  260.       dirlen = filename - pattern;
  261.       dirname = (char *) __alloca (dirlen + 1);
  262.       memcpy (dirname, pattern, dirlen);
  263.       dirname[dirlen] = '\0';
  264.       ++filename;
  265.     }
  266.  
  267.   if (filename[0] == '\0' && dirlen > 1)
  268.     /* "pattern/".  Expand "pattern", appending slashes.  */
  269.     {
  270.       int ret = glob (dirname, flags | GLOB_MARK, errfunc, pglob);
  271.       if (ret == 0)
  272.     pglob->gl_flags = (pglob->gl_flags & ~GLOB_MARK) | (flags & GLOB_MARK);
  273.       return ret;
  274.     }
  275.  
  276.   if (!(flags & GLOB_APPEND))
  277.     {
  278.       pglob->gl_pathc = 0;
  279.       pglob->gl_pathv = NULL;
  280.     }
  281.  
  282.   oldcount = pglob->gl_pathc;
  283.  
  284.   if (glob_pattern_p (dirname, !(flags & GLOB_NOESCAPE)))
  285.     {
  286.       /* The directory name contains metacharacters, so we
  287.      have to glob for the directory, and then glob for
  288.      the pattern in each directory found.  */
  289.       glob_t dirs;
  290.       register int i;
  291.  
  292.       status = glob (dirname,
  293.              ((flags & (GLOB_ERR | GLOB_NOCHECK | GLOB_NOESCAPE)) |
  294.               GLOB_NOSORT),
  295.              errfunc, &dirs);
  296.       if (status != 0)
  297.     return status;
  298.  
  299.       /* We have successfully globbed the preceding directory name.
  300.      For each name we found, call glob_in_dir on it and FILENAME,
  301.      appending the results to PGLOB.  */
  302.       for (i = 0; i < dirs.gl_pathc; ++i)
  303.     {
  304.       int oldcount;
  305.  
  306. #ifdef    SHELL
  307.       {
  308.         /* Make globbing interruptible in the bash shell. */
  309.         extern int interrupt_state;
  310.  
  311.         if (interrupt_state)
  312.           {
  313.         globfree (&dirs);
  314.         globfree (&files);
  315.         return GLOB_ABEND;
  316.           }
  317.       }
  318. #endif /* SHELL.  */
  319.  
  320.       oldcount = pglob->gl_pathc;
  321.       status = glob_in_dir (filename, dirs.gl_pathv[i],
  322.                 (flags | GLOB_APPEND) & ~GLOB_NOCHECK,
  323.                 errfunc, pglob);
  324.       if (status == GLOB_NOMATCH)
  325.         /* No matches in this directory.  Try the next.  */
  326.         continue;
  327.  
  328.       if (status != 0)
  329.         {
  330.           globfree (&dirs);
  331.           globfree (pglob);
  332.           return status;
  333.         }
  334.  
  335.       /* Stick the directory on the front of each name.  */
  336.       if (prefix_array (dirs.gl_pathv[i],
  337.                 &pglob->gl_pathv[oldcount],
  338.                 pglob->gl_pathc - oldcount))
  339.         {
  340.           globfree (&dirs);
  341.           globfree (pglob);
  342.           return GLOB_NOSPACE;
  343.         }
  344.     }
  345.  
  346.       flags |= GLOB_MAGCHAR;
  347.  
  348.       if (pglob->gl_pathc == oldcount)
  349.     /* No matches.  */
  350.     if (flags & GLOB_NOCHECK)
  351.       {
  352.         size_t len = strlen (pattern) + 1;
  353.         char *patcopy = (char *) malloc (len);
  354.         if (patcopy == NULL)
  355.           return GLOB_NOSPACE;
  356.         memcpy (patcopy, pattern, len);
  357.  
  358.         pglob->gl_pathv
  359.           = (char **) realloc (pglob->gl_pathv,
  360.                    (pglob->gl_pathc +
  361.                     ((flags & GLOB_DOOFFS) ?
  362.                      pglob->gl_offs : 0) +
  363.                     1 + 1) *
  364.                    sizeof (char *));
  365.         if (pglob->gl_pathv == NULL)
  366.           {
  367.         free (patcopy);
  368.         return GLOB_NOSPACE;
  369.           }
  370.  
  371.         if (flags & GLOB_DOOFFS)
  372.           while (pglob->gl_pathc < pglob->gl_offs)
  373.         pglob->gl_pathv[pglob->gl_pathc++] = NULL;
  374.  
  375.         pglob->gl_pathv[pglob->gl_pathc++] = patcopy;
  376.         pglob->gl_pathv[pglob->gl_pathc] = NULL;
  377.         pglob->gl_flags = flags;
  378.       }
  379.     else
  380.       return GLOB_NOMATCH;
  381.     }
  382.   else
  383.     {
  384.       status = glob_in_dir (filename, dirname, flags, errfunc, pglob);
  385.       if (status != 0)
  386.     return status;
  387.  
  388.       if (dirlen > 0)
  389.     {
  390.       /* Stick the directory on the front of each name.  */
  391.       if (prefix_array (dirname,
  392.                 &pglob->gl_pathv[oldcount],
  393.                 pglob->gl_pathc - oldcount))
  394.         {
  395.           globfree (pglob);
  396.           return GLOB_NOSPACE;
  397.         }
  398.     }
  399.     }
  400.  
  401.   if (!(flags & GLOB_NOSORT))
  402.     /* Sort the vector.  */
  403.     qsort ((__ptr_t) & pglob->gl_pathv[oldcount],
  404.        pglob->gl_pathc - oldcount,
  405.        sizeof (char *), collated_compare);
  406.  
  407.   return 0;
  408. }
  409.  
  410.  
  411. /* Free storage allocated in PGLOB by a previous `glob' call.  */
  412. void
  413. globfree (pglob)
  414.      register glob_t *pglob;
  415. {
  416.   if (pglob->gl_pathv != NULL)
  417.     {
  418.       register int i;
  419.       for (i = 0; i < pglob->gl_pathc; ++i)
  420.     if (pglob->gl_pathv[i] != NULL)
  421.       free ((__ptr_t) pglob->gl_pathv[i]);
  422.       free ((__ptr_t) pglob->gl_pathv);
  423.     }
  424. }
  425.  
  426.  
  427. /* Do a collated comparison of A and B.  */
  428. static int
  429. collated_compare (a, b)
  430.      const __ptr_t a;
  431.      const __ptr_t b;
  432. {
  433.   const char *const s1 = *(const char *const * const) a;
  434.   const char *const s2 = *(const char *const * const) b;
  435.  
  436.   if (s1 == s2)
  437.     return 0;
  438.   if (s1 == NULL)
  439.     return 1;
  440.   if (s2 == NULL)
  441.     return -1;
  442.   return strcoll (s1, s2);
  443. }
  444.  
  445.  
  446. /* Prepend DIRNAME to each of N members of ARRAY, replacing ARRAY's
  447.    elements in place.  Return nonzero if out of memory, zero if successful.
  448.    A slash is inserted between DIRNAME and each elt of ARRAY,
  449.    unless DIRNAME is just "/".  Each old element of ARRAY is freed.  */
  450. static int
  451. prefix_array (dirname, array, n)
  452.      const char *dirname;
  453.      char **array;
  454.      const size_t n;
  455. {
  456.   register size_t i;
  457.   size_t dirlen = strlen (dirname);
  458.  
  459.   if (dirlen == 1 && dirname[0] == '/')
  460.     /* DIRNAME is just "/", so normal prepending would get us "//foo".
  461.        We want "/foo" instead, so don't prepend any chars from DIRNAME.  */
  462.     dirlen = 0;
  463.  
  464.   for (i = 0; i < n; ++i)
  465.     {
  466.       size_t eltlen = strlen (array[i]) + 1;
  467.       char *new = (char *) malloc (dirlen + 1 + eltlen);
  468.       if (new == NULL)
  469.     {
  470.       while (i > 0)
  471.         free ((__ptr_t) array[--i]);
  472.       return 1;
  473.     }
  474.  
  475.       memcpy (new, dirname, dirlen);
  476.       new[dirlen] = '/';
  477.       memcpy (&new[dirlen + 1], array[i], eltlen);
  478.       free ((__ptr_t) array[i]);
  479.       array[i] = new;
  480.     }
  481.  
  482.   return 0;
  483. }
  484.  
  485.  
  486. /* Return nonzero if PATTERN contains any metacharacters.
  487.    Metacharacters can be quoted with backslashes if QUOTE is nonzero.  */
  488. static int
  489. glob_pattern_p (pattern, quote)
  490.      const char *pattern;
  491.      const int quote;
  492. {
  493.   register const char *p;
  494.   int open = 0;
  495.  
  496.   for (p = pattern; *p != '\0'; ++p)
  497.     switch (*p)
  498.       {
  499.       case '?':
  500.       case '*':
  501.     return 1;
  502.  
  503.       case '\\':
  504.     if (quote)
  505.       ++p;
  506.     break;
  507.  
  508.       case '[':
  509.     open = 1;
  510.     break;
  511.  
  512.       case ']':
  513.     if (open)
  514.       return 1;
  515.     break;
  516.       }
  517.  
  518.   return 0;
  519. }
  520.  
  521.  
  522. /* Like `glob', but PATTERN is a final pathname component,
  523.    and matches are searched for in DIRECTORY.
  524.    The GLOB_NOSORT bit in FLAGS is ignored.  No sorting is ever done.
  525.    The GLOB_APPEND flag is assumed to be set (always appends).  */
  526. static int
  527. glob_in_dir (pattern, directory, flags, errfunc, pglob)
  528.      const char *pattern;
  529.      const char *directory;
  530.      int flags;
  531.      int (*errfunc) __P ((const char *, int));
  532.      glob_t *pglob;
  533. {
  534.   __ptr_t stream;
  535.  
  536.   struct globlink
  537.     {
  538.       struct globlink *next;
  539.       char *name;
  540.     };
  541.   struct globlink *names = NULL;
  542.   size_t nfound = 0;
  543.  
  544.   if (!glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE)))
  545.     {
  546.       stream = NULL;
  547.       flags |= GLOB_NOCHECK;
  548.     }
  549.   else
  550.     {
  551.       flags |= GLOB_MAGCHAR;
  552.  
  553.       stream = (__glob_opendir_hook ? (*__glob_opendir_hook) (directory)
  554.         : (__ptr_t) opendir (directory));
  555.       if (stream == NULL)
  556.     {
  557.       if ((errfunc != NULL && (*errfunc) (directory, errno)) ||
  558.           (flags & GLOB_ERR))
  559.         return GLOB_ABEND;
  560.     }
  561.       else
  562.     while (1)
  563.       {
  564.         const char *name;
  565.         size_t len;
  566.  
  567.         if (__glob_readdir_hook)
  568.           {
  569.         name = (*__glob_readdir_hook) (stream);
  570.         if (name == NULL)
  571.           break;
  572.         len = 0;
  573.           }
  574.         else
  575.           {
  576.         struct dirent *d = readdir ((DIR *) stream);
  577.         if (d == NULL)
  578.           break;
  579.         if (! REAL_DIR_ENTRY (d))
  580.           continue;
  581.         name = d->d_name;
  582. #ifdef    HAVE_D_NAMLEN
  583.         len = d->d_namlen;
  584. #else
  585.         len = 0;
  586. #endif
  587.           }
  588.         
  589.         if (fnmatch (pattern, name,
  590.              (!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) |
  591.              ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)) == 0)
  592.           {
  593.         struct globlink *new
  594.           = (struct globlink *) __alloca (sizeof (struct globlink));
  595.         if (len == 0)
  596.           len = strlen (name);
  597.         new->name
  598.           = (char *) malloc (len + ((flags & GLOB_MARK) ? 1 : 0) + 1);
  599.         if (new->name == NULL)
  600.           goto memory_error;
  601.         memcpy ((__ptr_t) new->name, name, len);
  602.         if (flags & GLOB_MARK)
  603.           new->name[len++] = '/';
  604.         new->name[len] = '\0';
  605.         new->next = names;
  606.         names = new;
  607.         ++nfound;
  608.           }
  609.       }
  610.     }
  611.  
  612.   if (nfound == 0 && (flags & GLOB_NOCHECK))
  613.     {
  614.       size_t len = strlen (pattern);
  615.       nfound = 1;
  616.       names = (struct globlink *) __alloca (sizeof (struct globlink));
  617.       names->next = NULL;
  618.       names->name = (char *) malloc (len + ((flags & GLOB_MARK) ? 1 : 0) + 1);
  619.       if (names->name == NULL)
  620.     goto memory_error;
  621.       memcpy (names->name, pattern, len);
  622.       if (flags & GLOB_MARK)
  623.     names->name[len++] = '/';
  624.       names->name[len] = '\0';
  625.     }
  626.  
  627.   pglob->gl_pathv
  628.     = (char **) realloc (pglob->gl_pathv,
  629.              (pglob->gl_pathc +
  630.               ((flags & GLOB_DOOFFS) ? pglob->gl_offs : 0) +
  631.               nfound + 1) *
  632.              sizeof (char *));
  633.   if (pglob->gl_pathv == NULL)
  634.     goto memory_error;
  635.  
  636.   if (flags & GLOB_DOOFFS)
  637.     while (pglob->gl_pathc < pglob->gl_offs)
  638.       pglob->gl_pathv[pglob->gl_pathc++] = NULL;
  639.  
  640.   for (; names != NULL; names = names->next)
  641.     pglob->gl_pathv[pglob->gl_pathc++] = names->name;
  642.   pglob->gl_pathv[pglob->gl_pathc] = NULL;
  643.  
  644.   pglob->gl_flags = flags;
  645.  
  646.   if (stream != NULL)
  647.     {
  648.       int save = errno;
  649.       if (__glob_closedir_hook)
  650.     (*__glob_closedir_hook) (stream);
  651.       else
  652.     (void) closedir ((DIR *) stream);
  653.       errno = save;
  654.     }
  655.   return nfound == 0 ? GLOB_NOMATCH : 0;
  656.  
  657.  memory_error:
  658.   {
  659.     int save = errno;
  660.     if (__glob_closedir_hook)
  661.       (*__glob_closedir_hook) (stream);
  662.     else
  663.       (void) closedir ((DIR *) stream);
  664.     errno = save;
  665.   }
  666.   while (names != NULL)
  667.     {
  668.       if (names->name != NULL)
  669.     free ((__ptr_t) names->name);
  670.       names = names->next;
  671.     }
  672.   return GLOB_NOSPACE;
  673. }
  674.  
  675. #endif    /* _LIBC or not __GNU_LIBRARY__.  */
  676.